import request from "@/utils/request";
import { MenuQuery, MenuVO, MenusForm, ShortcutMenu } from "./types";
import { AxiosPromise } from "axios";

/**
 * 获取路由列表
 */
export function listRoutes() {
  return request({
    url: "/admin/permission/getAll",
    method: "get",
    params: {
      type: "element-plus",
    },
  });
}

export function getAll() {
  return request({
    url: "/admin/permission/getSelectData",
    method: "get",
  });
}

export function getShortcutMenu(): AxiosPromise<ShortcutMenu[]> {
  return request({
    url: "/admin/permission/shortcut",
    method: "get",
  });
}

export function getData(queryParams?: MenuQuery) {
  return request({
    url: "/admin/permission/getData",
    method: "get",
    params: queryParams,
  });
}

export function permissionDisable(data: any) {
  return request({
    url: "/admin/permission/disable",
    method: "post",
    data,
  });
}

export function shortcutMenu(data: any) {
  return request({
    url: "/admin/permission/shortcutMenu",
    method: "post",
    data,
  });
}

export function getMyShortcutMenu(): AxiosPromise<MenuVO[]> {
  return request({
    url: "/admin/permission/myShortcutMenu",
    method: "get",
  });
}

export function permissionEnable(data: any) {
  return request({
    url: "/admin/permission/enable",
    method: "post",
    data,
  });
}

export function createPermission(data: any) {
  return request({
    url: "/admin/permission/add",
    method: "post",
    data,
  });
}

export function updatePermission(data: any) {
  return request({
    url: "/admin/permission/edit",
    method: "put",
    data,
  });
}

export function delPermission(data: any) {
  return request({
    url: "/admin/permission/del",
    method: "delete",
    data,
  });
}

export function getMenuForm(ids: number): AxiosPromise<MenusForm> {
  return request({
    url: "/admin/permission/edit",
    method: "get",
    params: {
      ids: ids,
    },
  });
}
